home *** CD-ROM | disk | FTP | other *** search
/ Ubisoft Digital Press Ki….S.A./North America (USA) / Ubisoft Digital Press Kit 99 U.S.A.-North America (USA).bin / Dcr / language2.cst / 00004_Script_Scroll Text Beh < prev    next >
Text File  |  1999-05-03  |  3KB  |  101 lines

  1.  
  2.  
  3. -- Scroll Text Behavior
  4. ---------------------------------------------------------------
  5. -- This behavior the text in response to messages from the 
  6. -- arrow buttons, track, or indicator.
  7. --
  8. -- You attach this behavior to a text sprite.
  9. --
  10. -- 10/22/97 David Benman
  11. ---------------------------------------------------------------
  12.  
  13.  
  14. -- pTextSprite - the behavior's sprite.
  15. -- pTextMember - member reference for the text member in the sprite.
  16. -- pTextLowerLimit - lower limit for the text scrolling.
  17. -- pTextRange - entire range the text scrolls.
  18. -- pLineSize - the amount the text scrolls when the
  19. -- user clicks a button once. Usually the line height.
  20. property  onetime, pTextSprite, pTextMember, pTextLowerLImit, pTextRange, pLineSize, pPageSize, pTextOrigin
  21.  
  22. on beginsprite me
  23.   set onetime to 1
  24. end
  25.  
  26. -- This handler initializes several properties, sets the limits
  27. -- for the text scrolling, and scrolls the text to its beginning
  28. -- position.
  29. on exitframe me
  30.     if onetime = 1 then    
  31.     set pLineSize to 13
  32.     set totalLines to 15
  33.     set pPageSize to totalLines * pLineSize
  34.     set pTextOrigin to 255
  35.     
  36.     set pTextSprite to the spriteNum of me
  37.     set pTextMember to the member of sprite pTextSprite
  38.     
  39.     set lastOffset to integer(0.5 * totalLines) * plineSize
  40.     set textUpperLimit to the height of member pTextMember - lastOffset
  41.     set pTextLowerLimit to 0
  42.     set pTextRange to textUpperLimit - pTextLowerLimit
  43.     
  44.     set the locV of sprite pTextSprite to pTextOrigin
  45.     
  46.     set onetime = onetime + 1
  47.   end if  
  48. end
  49.  
  50.  
  51. -- This handler scrolls the text in response to messages from the
  52. -- arrow buttons, track,  or indicator.
  53. -- direction - either a symbol indicating the direction of scrolling
  54. -- or a proportion to indicate a specific position.
  55. -- scrollType - contains the symbol #page when scrolling should
  56. -- be by page.
  57. on scrollText me, direction, scrollType
  58.   
  59.   -- Sets the scrollAmount either a line or page depending on
  60.   -- the value for scrollType.
  61.   case TRUE of
  62.     (voidP(scrollType)):
  63.       set scrollAmount to pLineSize
  64.     (scrollType = #page):
  65.       set scrollAmount to pPageSize
  66.   end case
  67.   
  68.   -- Determines the next scroll position for the text. Sets the
  69.   -- next position to plus or minus one line, one page, or a specific
  70.   -- position depending on the value of direction.
  71.   if symbolP(direction) then
  72.     
  73.     case direction of
  74.       #down: set scrollDirection to 1
  75.       #up: set scrollDirection to -1
  76.     end case
  77.     
  78.     set scrollVector to scrollAmount * scrollDirection
  79.     set currentPosition to pTextOrigin -the locV of sprite pTextSprite
  80.     set nextPosition to currentPosition + scrollVector
  81.     
  82.     if nextPosition > pTextLowerLimit + pTextRange then
  83.       set nextPosition to pTextLowerLimit + pTextRange
  84.     else
  85.       if nextPosition < pTextLowerLimit then
  86.         set nextPosition to pTextLowerLimit
  87.       end if
  88.     end if
  89.     
  90.   else
  91.     set nextPosition to direction * pTextRange
  92.   end if
  93.   
  94.   -- Sets the text to the next position.
  95.   set the locV of sprite pTextSprite to pTextOrigin - nextPosition
  96.   
  97.   -- Sends a message to position the indicator to match the text.
  98.   sendAllSprites(#positionIndicator, float(nextPosition)/pTextRange)
  99.   
  100. end
  101.